home *** CD-ROM | disk | FTP | other *** search
/ Motor Sport Digital Archive Collection 1960s / Motor Sport Digital Archive Collection 1960s.iso / main.swf / scripts / mx / logging / LogLogger.as < prev   
Encoding:
Text File  |  2008-05-21  |  3.9 KB  |  134 lines

  1. package mx.logging
  2. {
  3.    import flash.events.EventDispatcher;
  4.    import flash.system.ApplicationDomain;
  5.    import mx.core.mx_internal;
  6.    import mx.resources.ResourceBundle;
  7.    
  8.    use namespace mx_internal;
  9.    
  10.    public class LogLogger extends EventDispatcher implements ILogger
  11.    {
  12.       private static var resourceLevelLimit:String;
  13.       
  14.       mx_internal static const VERSION:String = "2.0.1.0";
  15.       
  16.       private static var packageResources:ResourceBundle = ResourceBundle.getResourceBundle("logging",ApplicationDomain.currentDomain);
  17.       
  18.       loadResources();
  19.       
  20.       private var _category:String;
  21.       
  22.       public function LogLogger(param1:String)
  23.       {
  24.          super();
  25.          _category = param1;
  26.       }
  27.       
  28.       private static function loadResources() : void
  29.       {
  30.          resourceLevelLimit = packageResources.getString("levelLimit");
  31.       }
  32.       
  33.       public function log(param1:int, param2:String, ... rest) : void
  34.       {
  35.          var _loc4_:uint = 0;
  36.          if(param1 < LogEventLevel.DEBUG)
  37.          {
  38.             throw new ArgumentError(resourceLevelLimit);
  39.          }
  40.          if(hasEventListener(LogEvent.LOG))
  41.          {
  42.             _loc4_ = 0;
  43.             while(_loc4_ < rest.length)
  44.             {
  45.                param2 = param2.replace(new RegExp("\\{" + _loc4_ + "\\}","g"),rest[_loc4_]);
  46.                _loc4_++;
  47.             }
  48.             dispatchEvent(new LogEvent(param2,param1));
  49.          }
  50.       }
  51.       
  52.       public function get category() : String
  53.       {
  54.          return _category;
  55.       }
  56.       
  57.       public function error(param1:String, ... rest) : void
  58.       {
  59.          var _loc3_:uint = 0;
  60.          if(hasEventListener(LogEvent.LOG))
  61.          {
  62.             _loc3_ = 0;
  63.             while(_loc3_ < rest.length)
  64.             {
  65.                param1 = param1.replace(new RegExp("\\{" + _loc3_ + "\\}","g"),rest[_loc3_]);
  66.                _loc3_++;
  67.             }
  68.             dispatchEvent(new LogEvent(param1,LogEventLevel.ERROR));
  69.          }
  70.       }
  71.       
  72.       public function debug(param1:String, ... rest) : void
  73.       {
  74.          var _loc3_:uint = 0;
  75.          if(hasEventListener(LogEvent.LOG))
  76.          {
  77.             _loc3_ = 0;
  78.             while(_loc3_ < rest.length)
  79.             {
  80.                param1 = param1.replace(new RegExp("\\{" + _loc3_ + "\\}","g"),rest[_loc3_]);
  81.                _loc3_++;
  82.             }
  83.             dispatchEvent(new LogEvent(param1,LogEventLevel.DEBUG));
  84.          }
  85.       }
  86.       
  87.       public function fatal(param1:String, ... rest) : void
  88.       {
  89.          var _loc3_:uint = 0;
  90.          if(hasEventListener(LogEvent.LOG))
  91.          {
  92.             _loc3_ = 0;
  93.             while(_loc3_ < rest.length)
  94.             {
  95.                param1 = param1.replace(new RegExp("\\{" + _loc3_ + "\\}","g"),rest[_loc3_]);
  96.                _loc3_++;
  97.             }
  98.             dispatchEvent(new LogEvent(param1,LogEventLevel.FATAL));
  99.          }
  100.       }
  101.       
  102.       public function warn(param1:String, ... rest) : void
  103.       {
  104.          var _loc3_:uint = 0;
  105.          if(hasEventListener(LogEvent.LOG))
  106.          {
  107.             _loc3_ = 0;
  108.             while(_loc3_ < rest.length)
  109.             {
  110.                param1 = param1.replace(new RegExp("\\{" + _loc3_ + "\\}","g"),rest[_loc3_]);
  111.                _loc3_++;
  112.             }
  113.             dispatchEvent(new LogEvent(param1,LogEventLevel.WARN));
  114.          }
  115.       }
  116.       
  117.       public function info(param1:String, ... rest) : void
  118.       {
  119.          var _loc3_:uint = 0;
  120.          if(hasEventListener(LogEvent.LOG))
  121.          {
  122.             _loc3_ = 0;
  123.             while(_loc3_ < rest.length)
  124.             {
  125.                param1 = param1.replace(new RegExp("\\{" + _loc3_ + "\\}","g"),rest[_loc3_]);
  126.                _loc3_++;
  127.             }
  128.             dispatchEvent(new LogEvent(param1,LogEventLevel.INFO));
  129.          }
  130.       }
  131.    }
  132. }
  133.  
  134.